//
//  CATransaction+ModalAnimation.m
//  UIControls
//
//  Created by 21CN Vgo on 12-7-13.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "CATransaction+ModalAnimation.h"

@implementation CATransaction (ModalAnimationHelper)

+ (void) beginModalAnimations:(CFTimeInterval)duration
{
	// AssetForURL Block
	void (^CompletionBlock)(void) = ^(void)
	{
		CFRunLoopStop(CFRunLoopGetCurrent());
	};
	
	[CATransaction setCompletionBlock:CompletionBlock];
	
	[CATransaction setAnimationDuration:duration];
	
	[CATransaction begin];
}

+ (void) commitModalAnimations  
{
	[CATransaction commit];
	
	CFRunLoopRun();
	
	[CATransaction setCompletionBlock:nil];
}

@end
